<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var pivotArray = function (nums, pivot) {
      nums.sort((a, b) => {
        if ((a - pivot) * (b - pivot) <= 0) {
          return a - b;
        }
        return 1;
      })
      return nums;
    };
    console.log(pivotArray([9, 12, 5, 10, 14, 3, 10], 10));
  </script>
</body>

</html>